package com.casic.ops.entity.dto.pipeline;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import com.casic.ops.consts.user.UserHolder;
import com.casic.ops.utils.OpsSnowFlake;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 流水线节点类型DTO
 * @author cww
 * @date 2022/6/17
 */
@Data
@Accessors(chain = true)
public class PipelineNodeTemplateDTO extends CommonDTO{
    /**
     * 唯一标示做关联
     */
    @JSONField(serializeUsing = ToStringSerializer.class)
    private long parentUuid;
    /**
     * 标签
     */
    private String label;
    /**
     * 标识
     */
    private String name;
    /**
     * 描述
     */
    private String nodDescription;
    /**
     * 图标
     */
    private String icon;
    /**
     * 节点类型：目录 or 节点
     */
    private Integer type;
    /**
     * 子节点
     */
    private List<PipelineNodeTemplateDTO> children = new ArrayList<>();

    public void init(){
        this.setCreator(UserHolder.get().getUsername());
        this.setModifier(UserHolder.get().getUsername());
        Date date = new Date();
        this.setGmtCreate(date);
        this.setGmtModified(date);
        this.setUuid(OpsSnowFlake.getInstance().nextId());
    }
}
